#include <future>
#include <mutex>
#include <thread>
#include <iostream>

using namespace std;

static int task() {
	int k;
	cout << "Entrez un entier ou un caractère : ";
	cin >> k;
	return k;
}

static packaged_task<int ()> pt(task);
static future<int> f = pt.get_future();
static mutex ecran;

static void thread1() {
	unique_lock<mutex> ul(ecran);
	cout << "Voici le thread 1" << endl;
	ul.unlock();
	pt();
}

static void thread2() {
	unique_lock<mutex> ul(ecran);
	cout << "Voici le thread 2" << endl;
	ul.unlock();
	int k = f.get();
	cout << "Vous avez entré " << k << endl;
}

int main(int argc, char** argv) {
	thread t1(thread1);
	thread t2(thread2);
	t1.join();
	t2.join();
	return 0;
}

